<?php

namespace App\Http\Requests\Backend\Loan;

use App\Models\LoanApply;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ActionLoanException extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'loan_status' => [
                'bail',
                'required',
                Rule::in([
                    LoanApply::LOAN_CHANGE_CARD,
                    LoanApply::LOAN_CHANGE_CARD_HANDLING,
                    LoanApply::LOAN_HANDLE_CHANGE_CARD_SUCCESS,
                    LoanApply::LOAN_HANDLE_CHANGE_CARD_FAIL,
                    ])
            ],
            'loan_money' => 'nullable|numeric',
            'bank_card_num' => 'nullable',
            'loan_time' => 'nullable|date',
        ];
    }


    public  function   messages()
    {
      return [
          'loan_status.required' =>  '缺少放款要变更的状态',
          'loan_status.in' => '处理状态值非法，请确认操作',
          'loan_money.numeric' => '放款金额必须为数字',
          'bank_card_num.numeric' => '银行卡号必须为数字',
          'loan_time.date' => '放款日期格式非法',
      ];
    }
}
